<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DecimalFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*"%>
<%@ page import="com.qingke.stockdata.model.*" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>轻课股票数据分析系统</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="css/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/sb-admin-2.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="css/morris.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">

	<style type="text/css">
		.info{
			color: red;
		}
	</style>
</head>

<body>
    <div id="wrapper">
        <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index">轻课网股票数据分析系统</a>
            </div>
            <!-- /.navbar-header -->

            <ul class="nav navbar-top-links navbar-right">
      
                <!-- /.dropdown -->
                <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="#"><i class="fa fa-user fa-fw"></i>修改密码</a>
                        </li>
                        <li class="divider"></li>
                        <li><a href="login.html"><i class="fa fa-sign-out fa-fw"></i>退出</a>
                        </li>
                    </ul>
                    <!-- /.dropdown-user -->
                </li>
                <!-- /.dropdown -->
            </ul>
            <!-- /.navbar-top-links -->

            <div class="navbar-default sidebar" role="navigation">
                <div class="sidebar-nav navbar-collapse">
                    <ul class="nav" id="side-menu">
                        <li class="sidebar-search">
                            <div class="input-group custom-search-form">
                                <input type="text" class="form-control" placeholder="搜索...">
                                <span class="input-group-btn">
                                <button class="btn btn-default" type="button">
                                    <i class="fa fa-search"></i>
                                </button>
                            </span>
                            </div>
                            <!-- /input-group -->
                        </li>
                        <li>
                            <a href="index"><i class="fa fa-dashboard fa-fw"></i>首页</a>
                        </li>
                        <li>
                            <a href="index"><i class="fa fa-dashboard fa-fw"></i>添加</a>
                        </li>
                        <li>
                            <a href="index"><i class="fa fa-dashboard fa-fw"></i>今日最佳</a>
                        </li>
                        <li>
                            <a href="index"><i class="fa fa-dashboard fa-fw"></i>今日推荐</a>
                        </li>
                    </ul>
                </div>
                <!-- /.sidebar-collapse -->
            </div>
            <!-- /.navbar-static-side -->
        </nav>
		<%
			String state = (String)request.getAttribute("state");
			Stock stock = (Stock)request.getAttribute("stock");
			List<StockData> list = (List<StockData>)request.getAttribute("stockdata");
			String code = request.getParameter("code");
			out.print(code);
		%>
		<%!
			String ratioOf(double open,double close){
				DecimalFormat df = new DecimalFormat("#0.00");
				String ratio = "";
				if((close - open) < 0){
					ratio+="-";
					double result = (open-close)/open*100;
					ratio+=df.format(result);
				} else{
					double result = (close-open)/open*100;
					ratio+=df.format(result);
				}
				ratio+="%";
				return ratio;
			}
		%>

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"><%=stock.getName()%></h1>
                    <h6 class="info"><%=state%></h6>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">

                <div class="col-lg-12">
                    
                <img src="images/sh601006.gif" alt="趋势曲线图">

                    <div class="panel panel-default">
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                               <table class="table">
                                    <thead>
                                        <tr>
                                            <th colspan="2">#</th>
                                            <th colspan="1">日期</th>
                                            <th colspan="1">开盘价</th>
                                            <th colspan="1">收盘价</th>
                                            <th colspan="1">当日涨跌</th>
                                        </tr>
                                    </thead>
                               		<%
                               			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                               			int count = 1;
                               			for(StockData sd:list){
                               		%>
                                    	<tbody>
                                        		<tr class="success">
                                            	<td colspan="2"><%=count%></td>
                                            	<td colspan="1"><%=sdf.format(sd.getDate()) %></td>
                                            	<td colspan="1">￥<%=sd.getOpen() %></td>
                                            	<td colspan="1">￥<%=sd.getClose() %></td>
                                            	<td colspan="1"><%=ratioOf(sd.getOpen(), sd.getClose()) %></td>
                                        	</tr>
                                    	</tbody>
                               		<%
                               			count++;
                               			}
                               		%>
                                </table>

                            <!-- /.table-responsive -->
                            
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
    
    
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="js/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="js/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="js/dataTables.bootstrap.min.js"></script>
    <script src="js/dataTables.responsive.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="js/sb-admin-2.js"></script>

    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true
        });
    });
    </script>

</body>

</html>
